    /**
     *  <div class="toast-warpper">
     *       <div class="toast-icon">↑</div>
     *      <div class="toast-text">vvv</div>
     * </div>
     */
    let option = {
        type: 1, //1 成功 2 失败 3，警告 4 错误
        time: 2000,
        icon: '' //最好字体图标，或者图片
    }

    class Toast {
        constructor(text = '加载中...', options = option) {
            this.text = text;
            this.options = options;
            this.init()
        };

        init() {
            this.createHtml()
        }
        createHtml() {
            let imgReg = /\.(gif|jpg|jpeg|png|bmp|GIF|JPG|PNG)$/;
            let parentEl = this.createElementDom('div', 'toast-warpper');
            let childrenLeft = this.createElementDom('div', 'toast-icon');
            let childrenRight = this.createElementDom('div', 'toast-text');
            parentEl.appendChild(childrenLeft);
            parentEl.appendChild(childrenRight);
            document.body.appendChild(parentEl);
            childrenRight.innerHTML = this.text;

            if (imgReg.test(this.options.icon)) {
                let childrenIcon = this.createElementDom('img', '');
                childrenIcon.setAttribute('src', this.options.icon);
                childrenLeft.appendChild(childrenIcon)
            } else {
                let childrenIcon = this.createElementDom('i', this.options.icon);
                childrenLeft.appendChild(childrenIcon)
            }

            switch (this.options.type) {
                case 1:
                    this.success(parentEl)
                    break;
                case 2:
                    this.info(parentEl)
                    break;
                case 3:
                    this.warn(parentEl)
                    break;
                case 4:
                    this.error(parentEl)
                    break;
                default:
                    this.success(parentEl)
                    break;

            }
            setTimeout(() => {
                document.body.removeChild(pd);
            }, this.options.time || option.time)
        }
        success(pd) {
            pd.style.background = '#5cb85c'
        }
        info(pd) {
            pd.style.background = '#5bc0de';
        }
        warn(pd) {
            pd.style.background = '#f0ad4e';
        }
        error(pd) {
            pd.style.background = '#d9534f';
        }
        createElementDom(name, className) {
            let dom = document.createElement(name);
            className && (dom.className = className);
            return dom;
        }
    }
    export default Toast;